// $URL: http://mingw-lib.googlecode.com/svn/trunk/local/box/yt_new/widget.h $
// $Rev: 785 $
// $Author: akio.miyoshi $
// $Date:: 2012-10-11 10:10:04 +0000#$

#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QtCore>
#include <QtSql>
//#include "nam.h"
#include "batchnetworkaccessmanager.h"
#include "yt_rec.h"
#include "yt_web.h"

////#include "t_my_httpbackend.h"

namespace Ui {
    class Widget;
}

class Widget : public QWidget {
    Q_OBJECT
public:
    Widget(QWidget *parent = 0);
    ~Widget();

protected:
    void changeEvent(QEvent *e);

private:
    Ui::Widget *ui;
	T_VideoList m_video_list;
	//QString m_sort_type;
	QWebView *webView_2;
	QString m_lastSearch;
    BatchNetworkAccessManager *nam;
    ////T_MyBackendFactory m_factory;
    YtManager *yt;
    QSqlDatabase m_db;
    YtWeb *ytweb;
    void setDesktopFile(QFile &file, QString name);
    void saveDesktopFile(QString name, QByteArray bytes);

private slots:
    void on_pushButton_5_clicked();
    void on_pushButton_3_clicked();
    void on_pushButton_4_clicked();
    void on_pushButton_2_clicked();
    void on_pushButton_clicked();
public slots:
    void populateJavaScriptWindowObject1();
    void populateJavaScriptWindowObject2();
    void requestFinished(QNetworkReply *reply);
    void dbgmsg(QString a_msg);
	void submitFavoritePage(int a_page);
	void submitFavoritePage2(int a_page, QString a_id);
	void submitIdToBrowse(QString a_id);
    void submitIdToPlay(QString a_id);
    void submitIdToPlay2(QString a_id);
    void submitIdToRelated(QString a_id);
	void submitIdToDownload(QString a_id);
	void submitIdToReset(QString a_id);
	int submitIdToRaise(QString a_id);
    ////int submitIdToDelete(QString a_id);
    int submitIdToDelete(QString a_id, bool a_keep_in_db = false);
    void submitStreamToPlay(QString a_target);
	void openUrl(const QUrl &url);
	void slotEditFind();
	void slotEditFindNext();
	void slotEditFindPrevious();
	void openWithBrowser(QString a_url);
	void slot_sort_spec(QString a_type);
	void cmd_reload_db();
	void cmd_reload_web();
	void cmd_refresh_display();
public: signals:
    void answer_1(int a_1, int a_2);
	void answer_2(QStringList a_str_list);
	void answer_3(QObject *a_obj);
	//Page1.prototype.handle_vlc_player = function(a_target, a_title) {
};

#endif // WIDGET_H
